import java.util.Scanner;

public class StringDemo9 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个字符串将其准换成罗马数字");
        String[]arr={"Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ","Ⅸ"};
        StringBuilder sb=new StringBuilder();
        while (true) {
            String s=sc.next();
            Boolean bl=check(s);
            System.out.println(bl);
            if(bl==false){
                System.out.println("数字输入不符合规定,请重新输入");
            }else{
                for(int i=0;i<s.length();i++){   //8654
                    if(s.charAt(i)=='0'){        //如果是0则变成空
                        sb.append(" ");
                    }else {
                        sb.append(arr[s.charAt(i) - 49]);   //将字符串转换成罗马数字
                    }
                }
            }

            String s1=sb.toString();
            System.out.println(s1);
            sb.setLength(0);    //将StringBuilder重置成0 防止下次继续使用导致
        }

    }


    //判断字符串每个字符是否符合0-9
    public static boolean check(String s){
        if(s.length()>9){
            return false;
        }
        for(int i=0;i<s.length();i++){
            char a=s.charAt(i);
            if(a>='0'&&a<='9'){

            }else{
                return false;
            }
        }
        return true;
    }
}
